package knowse.app.controller;

import java.util.ArrayList;

import knowse.app.daos.CommitDAO;
import knowse.app.daos.CommitDataObject;

public class LogCommitController {
	
	ArrayList<CommitDataObject> commitArr;
	private static final String COMMIT_SIZE = "30";
	private static final Boolean IsDescending = true;
	
	public LogCommitController(){
		this.commitArr=getCommits();		
	}

	
	
	public ArrayList<CommitDataObject> getCommits() {
		CommitDAO cdao=new CommitDAO();	
		return cdao.fetchCommits(COMMIT_SIZE, IsDescending);
	}



	public ArrayList<String> getCommitsString() {
		ArrayList<String> cStrArr= new ArrayList<String>();
		for(int i=0;i<this.commitArr.size();i++){
			CommitDataObject cdo=this.commitArr.get(i);
			String str=cdo.getStartDate()+" "+cdo.getStartTime()
					+ " Author: "+cdo.getAuthorName() 
					+ " Number of Changes: " + cdo.getNumChanges();
			cStrArr.add(str);			
		}
		
		return cStrArr;
	}
	
	

	
	
}
